Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@babel/helper-define-polyfill-provider
Advanced tools
Babel helper to create your own polyfill provider
The @babel/helper-define-polyfill-provider package is part of the Babel ecosystem and is used to define a way to provide polyfills in your Babel configuration. It helps in specifying which polyfills to include based on the target environment and the features used in your code, ensuring that only necessary polyfills are added, thus optimizing the bundle size.
Define polyfill provider
This code sample demonstrates how to define a custom polyfill provider using the @babel/helper-define-polyfill-provider package. It specifies polyfills for 'Promise' and 'fetch' with their respective detection logic and paths to their polyfill modules.
import { createPolyfillProvider } from '@babel/helper-define-polyfill-provider';
const myPolyfillProvider = createPolyfillProvider({
name: 'myPolyfillProvider',
polyfills: {
'Promise': {
global: 'Promise',
detection: 'Promise in global',
path: 'core-js/modules/es.promise'
},
'fetch': {
global: 'fetch',
detection: 'fetch in global',
path: 'whatwg-fetch'
}
}
});
Similar to @babel/helper-define-polyfill-provider, @babel/preset-env is a Babel preset that allows you to specify a target environment and automatically determines the Babel plugins and polyfills you need. While @babel/preset-env is more comprehensive and widely used for setting up Babel configurations, @babel/helper-define-polyfill-provider offers more granular control over polyfill definitions.
Core-js is a modular standard library for JavaScript, including polyfills for ECMAScript up to 2021. It can be used directly or through @babel/preset-env. Unlike @babel/helper-define-polyfill-provider, which is a helper tool for defining polyfill providers, core-js provides actual implementations of polyfills and is often used as the underlying library for polyfilling in many environments.
Using npm:
npm install --save-dev @babel/helper-define-polyfill-provider
or using yarn:
yarn add @babel/helper-define-polyfill-provider --dev
FAQs
Babel helper to create your own polyfill provider
The npm package @babel/helper-define-polyfill-provider receives a total of 12,423,760 weekly downloads. As such, @babel/helper-define-polyfill-provider popularity was classified as popular.
We found that @babel/helper-define-polyfill-provider demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.